﻿using Microsoft.AspNetCore.Mvc;
using Nxg.Blog.Core;
using Nxg.Blog.Core.Commands;
using Nxg.Blog.Core.ViewProjections.Admin;

namespace Nxg.Blog.Web.Controllers {
    public class AdminController : SecureController {
        private readonly ICommandInvokerFactory _commandInvokerFactory;
        public AdminController (ICommandInvokerFactory commandInvokerFactory, IViewProjectionFactory viewProjectionFactory) : base (viewProjectionFactory) {
            _commandInvokerFactory = commandInvokerFactory;
        }
        public IActionResult Index () {
            var stat = _viewProjectionFactory.Get<AllStatisticsBindingModel, AllStatisticsViewModel> (new AllStatisticsBindingModel { TagThreshold = 1 });

            return View (stat);
        }

        public IActionResult Category (int page) {
            var model = _viewProjectionFactory.Get<CategoryManageBindingModel, CategoryManageViewModel> (new CategoryManageBindingModel {
                    Take = 15,
                        Page = page
                });
            return View (model);
        }
    }
}